﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace Felbot.Interface.Conversations {
    /// <summary>The Felbot Xml Document root for the log file.</summary>
    [XmlRootAttribute("FelbotLog", Namespace = "", IsNullable = false)]
    public class XmlConversationRoot {
        /// <summary>Creates object for serialization.</summary>
        public XmlConversationRoot() { }
        
        /// <summary>Gets the Users.fbx version.</summary>
        [XmlAttribute("version")]
        public double Version = 1.0;

        /// <summary>Gets the conversation.</summary>
        [XmlElement("conversation", IsNullable = true)]
        public XmlConversation Conversation;
    }

    /// <summary>The serializable <![CDATA[<conversation>]]> tag. Contains information on the line.</summary>
    [Serializable]
    public class XmlConversation {
        /// <summary>Creates object for serialization.</summary>
        public XmlConversation() { }

        /// <summary>Gets the list of user entries.</summary>
        [XmlArray("lines", IsNullable = true), XmlArrayItem("line", typeof(XmlLine), IsNullable = true)]
        public List<XmlLine> Lines = new List<XmlLine>();

        /// <summary>Gets or sets the time the conversation was started.</summary>
        [XmlAttribute("started")]
        public DateTime Started;

        /// <summary>Gets or sets the name of the profile the conversation occured in.</summary>
        [XmlAttribute("proname")]
        public string ProfileName;
    }

    /// <summary>The serializable <![CDATA[<line>]]> tag. Contains information on the line.</summary>
    [Serializable]
    public class XmlLine {
        /// <summary>Creates object for serialization.</summary>
        public XmlLine() { }

        /// <summary>Gets or sets timestamp of the line.</summary>
        [XmlAttribute("stamp")]
        public DateTime Stamp;

        /// <summary>Gets the list of text nodes.</summary>
        [XmlArray("nodes", IsNullable = true), XmlArrayItem("node", typeof(XmlTextNode), IsNullable = false)]
        public List<XmlTextNode> TextNodes = new List<XmlTextNode>();
    }

    /// <summary>The serializable<![CDATA[<node>]]> and <![CDATA[<edited>]]> tags. Contains information on the entries edits.</summary>
    [Serializable]
    public class XmlTextNode {
        /// <summary>Creates object for serialization.</summary>
        public XmlTextNode() { }

        /// <summary>Gets or sets the style of the node.</summary>
        [XmlAttribute("style")]
        public string Style;

        /// <summary>Gets or sets the text of the node.</summary>
        [XmlText]
        public string Text;
    }
}
